<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title><? echo $title ?></title>
<? require("lib.php"); ?>
</head>
<body>
<div class="content-box"><!-- Start Content Box -->
  <div class="content-box-header">
      <h3><? echo $title ?></h3>
      <div class="clear"></div>
  </div> <!-- End .content-box-header -->
  <div class="content-box-content">
<?
switch ($do) {
  case "add":
  add();
  break;
  case "update":
  update($info);
  break;
  case "delete":
  delete($id);
  break;
  case "flip":
  flip($id);
  break;
  case "set_default":
  set_default($id);
  break;
  default:
  show_info($info);
}
 ?>
<? function show_box($row, $iseditmode, $isadd=0){ 
	global $id, $h, $url, $title, $cate, $baseurl, $option, $arrlang;
  $is_default=1; if(isset($row['is_default']))$is_default=$row['is_default'];
?>
    	<table width="99%" cellspacing="0" cellpadding="3" class="mbox">
          <tr class="th"><td class="thtitle" width="120" align="right"><? echo $title ?></td>
            <td><? echo $h->hidden('id', iso($row["id"])); ?></td></tr>
          <?
            $str='';
            foreach($arrlang as $val){ // 加载所有启用的分语言的字段, add all fields that marked by languages
              $str.='<tr><td class="l">'.ROOT_NAME.'('.$val['name'].')</td><td>'.$h->text('name_'.$val['code'], iso($row["name_".$val['code']]), 'g').'</td></tr>';
            }
            echo $str;
          ?>
          <tr><td class="l"><?=ROOT_CURRENCY_CODE?></td><td><? echo $h->text('code', iso($row["code"]), 'gs') ?></td></tr>
          <tr><td class="l"><?=ROOT_CURRENCY_SIGN?></td><td><? echo $h->text('sign', iso($row["sign"]), 'gs') ?></td></tr>
          <tr><td class="l"><?=ROOT_CURRENCY_ABBREVIATION?></td><td><? echo $h->text('abbreviation', iso($row["abbreviation"]), 'gs') ?></td></tr>
          <tr><td class="l"><?=ROOT_EXCHANGE_RATE?></td><td><? echo $h->text('default_to_rate', iso($row["default_to_rate"]), 'gs') ?></td></tr>
          <tr><td class="l"><?=ROOT_ORDER?></td><td><? echo $h->text('seq_no', iso($row["seq_no"]), 'gs') ?> <span class="red"> <?=ROOT_HIGHER_NUMBER_IN_FRONT?></span></td></tr>
          <tr><td class="l">&nbsp;</td><td><br><? echo $h->submit('save', '&nbsp; '.ROOT_SAVE.' &nbsp;', $iseditmode==1?'':'hide') ?>&nbsp;&nbsp;<a onClick="history.go(-1)">[ <?=ROOT_CANCEL?> ]</a><br><br></td></tr>
        </table>
        <? } ?>
	<? function show_boxes($result){
		global $url, $page, $pages, $cateid, $cate, $s, $lang;
    		$str='<table width="99%" cellspacing="0" class="mlist"><tr class="th"><td><strong>#</strong></td><td><strong>'.ROOT_NAME.'</strong></td><td><strong>'.ROOT_CURRENCY_CODE.'</strong></td><td><strong>'.ROOT_EXCHANGE_RATE.'</strong></td><td><strong>'.ROOT_DEFAULT_CURRENCY.'</strong></td><td><strong>'.ROOT_ORDER.'</strong></td><td><a class="hide" href="'.$url.'.php?do=add">[ '.ROOT_ADD.' ]</a></td></tr>';
		$count=1;
    foreach( $result as $row)
		{
			$uid=decode($row['id']);
			$is_default='-'; if($row['is_default'])$is_default=ROOT_YES;
			$enable=$row['is_enabled']?ROOT_DISABLE:ROOT_ENABLE;
			$str.="<tr ".(($row['is_enabled'])?"":"class=\"disabled\"")."><td>".$uid.".</td><td><a href=\"$url.php?do=update&id=".$uid."\">".decode($row['name_'.$lang])."</a></td><td>".$row['code']."</td><td>".$row['default_to_rate']."</td><td>".$is_default."</td><td>".$row['seq_no']."</td><td><a href=\"$url.php?do=update&id=".decode($row['id'])."\">".ROOT_UPDATE."</a>";
			if(!$row['is_default'])$str.=" | <a href=\"$url.php?do=flip&cateid=$cateid&page=$page&id=".decode($row['id'])."\">".$enable."</a>";
			
			//actually don't allow to change default currency otherwise need to update all product cost to the new currency.  not a good idea.
			if(false&&!$row['is_default'])$str.=" | <a href=\"$url.php?do=set_default&id=".decode($row['id'])."\">".ROOT_DEFAULT."</a>";
			//$str.="	  | <a href=\"$url.php?do=delete&id=".decode($row['id'])."\" onClick=\"javascript: return delc();\">".ROOT_DELETE."</a>";
			$str.="</td></tr>";
			$count++;
		}
		$str.= "</table>";
		echo $str;
		if($count==1) echo "<br>".ROOT_NO_DATA."!";
		echo echo_page($page, $pages, $url.'-'.$cateid.'-p');
         } ?>
     <br class="clear" />
		</div> <!-- End .content-box-content -->
    <br class="clear" />
	</div><!-- End .content-box -->
</body>
</html>